package com.xx.controller;

import com.xx.dto.LoginUserDTO;
import com.xx.entity.Employees;
import com.xx.entity.R;
import com.xx.enums.HttpEnum;
import com.xx.service.IEmployeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/employeeLogin")
//允许跨域
@CrossOrigin
public class LoginController {

    @Autowired
    IEmployeesService employeesService;

    @PostMapping
    public R<Employees> login(@RequestBody @Valid LoginUserDTO loginUser) {
        Employees employees = employeesService.
                selectAllByLoginNameAndPassword(loginUser.getLoginName(), loginUser.getPassword());
        return R.success(employees);
    }
}
